package com.nbk.composition.utils

import com.fasterxml.jackson.core.type.TypeReference
import com.fasterxml.jackson.databind.ObjectMapper


/**
 * Author:  LuoHaoLun
 * Email :  506503279@qq.com
 * Date  :  2020/12/18
 */

var mapper: ObjectMapper = ObjectMapper()
fun Any.toJson(): String = mapper.writeValueAsString(this)
inline fun <reified T> String.fromJson(): T = mapper.readValue(this, object : TypeReference<T>() {})